package com.sgb.kjwl.view.ui.fragment.packers;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.bumptech.glide.Glide;
import com.google.android.material.tabs.TabLayout;
import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityFindPeopleBinding;
import com.sgb.kjwl.model.entity.FindPeopleEntity;
import com.sgb.kjwl.model.entity.packers.PickResultEntity;
import com.sgb.kjwl.model.entity.transport.GoodsInfoTypeEntity3;
import com.sgb.kjwl.model.entity.user.AddressEntity;
import com.sgb.kjwl.view.ui.activity.packers.FindPeopleDetailActivity;
import com.sgb.kjwl.view.ui.adapter.packers.FindPeopleAdapter;
import com.sgb.kjwl.view.widget.GoodsTypePopWindow4;
import com.sgb.kjwl.view.widget.PickPopWindow1;
import com.sgb.kjwl.view.widget.ThreeLevelAreaWindow;
import com.sgb.kjwl.viewmodel.packers.PackersFindPeopleModel;
import com.sgb.link.entity.PickFilterEntity;
import com.swgk.core.base.model.entity.SelectPopEntity;
import com.swgk.core.customview.ScreenChildTextView;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.interfaces.PopClick;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.recyclerview.decoration.RecyclerCustomDecoration;
import com.swgk.core.recyclerview.entity.BaseAreaEntity;
import com.swgk.core.util.PickSelectEntity;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.view.weiget.TwoLevelPopWindow;
import com.swgk.core.xrecyclerview.XRecyclerView;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : younghow
 * @date : 2021/12/3 11:29
 * description:工人大厅
 */
public class WorkerFragment extends AppLazyFragment {

    PackersFindPeopleModel viewModel;
    private ActivityFindPeopleBinding binding;
    private FindPeopleAdapter findPeopleAdapter;

    /**
     * 工种
     */
    private TwoLevelPopWindow<PickFilterEntity> popWorkType;
    private PickResultEntity pickResultIndustry;
    private PickResultEntity pickResultCategory;
    private PickResultEntity pickResultWorkType;
    /**
     * 专业职级
     */
    private PickPopWindow1 popWorkerLevel;
    private PickResultEntity pickResultWorkerLevel;
    /**
     * 工龄
     */
    private PickPopWindow1 popWorkYear;
    private PickResultEntity pickResultWorkYear;
    /**
     * 所在区域
     */
    private ThreeLevelAreaWindow popCity;
    private PickResultEntity pickResultProvince;
    private PickResultEntity pickResultCity;
    private PickResultEntity pickResultArea;
    private AddressEntity mAddress;
    private String time;
    private String mAreaCode, mAreaName,categoryNo = "",workNo = "";
    private boolean isLoadMore;
    private List<PickFilterEntity> oneLevel;
    private List<PickFilterEntity<List<PickFilterEntity<List<PickFilterEntity>>>>> workTypeList;
    private List<GoodsInfoTypeEntity3> carsTypeData;
    private GoodsTypePopWindow4 carsTypePopWindow;
    private int typePosition = -1;
    private SelectPopEntity selectPopEntity3;
    private String industryNo = "",workName = "";

    public static WorkerFragment newInstance() {
        return (new WorkerFragment());
    }

    public static WorkerFragment newInstance(String provinceNo,String cityNo,String cityName,String industryNo,String categoryNo,String workNo,String workName,String time) {
        WorkerFragment intent = new WorkerFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("provinceNo", provinceNo);
        bundle.putSerializable("industryNo", industryNo);
        bundle.putSerializable("categoryNo", categoryNo);
        bundle.putSerializable("workNo", workNo);
        bundle.putSerializable("cityNo", cityNo);
        bundle.putSerializable("cityName", cityName);
        bundle.putSerializable("workName", workName);
        bundle.putSerializable("time", time);
        intent.setArguments(bundle);
        return (intent);
    }

    private void initFilterData(boolean isLoadMore) {
        this.isLoadMore = isLoadMore;
        viewModel.getNewList(pickResultIndustry.getNo(), pickResultCategory.getNo(), pickResultWorkType.getNo(),
                pickResultWorkerLevel.getNo(), pickResultWorkYear.getNo(), pickResultProvince.getNo(),
                pickResultCity.getNo(), pickResultArea.getNo(), isLoadMore, time);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.activity_find_people, container, false);
        return binding.getRoot();
    }

    @Override
    protected void initView() {

        oneLevel = new ArrayList<>();
        carsTypeData = new ArrayList<>();

        binding.setLifecycleOwner(this);
        viewModel = new ViewModelProvider(this).get(PackersFindPeopleModel.class);

        binding.ivEmploymentAll.setOnClickListener(this);

        setTextButton();

        binding.sct.onSetCallPop(new ScreenChildTextView.ICallPop() {
            @Override
            public void openPop(int position, TextView content, LinearLayout bg, SelectPopEntity entity) {
                if (binding.sct.getSize() == 4){
                    if (position == 0) {
                        showWorkTypePop();
                    } else if (position == 1) {
                        shoWorkerLevelPop();
                    } else if (position == 2) {
                        shoWorkYearPop();
                    } else if (position == 3) {
                        showCityPop();
                    }
                }else if (binding.sct.getSize() == 3){
                    if (position == 0) {
                        shoWorkerLevelPop();
                    } else if (position == 1) {
                        shoWorkYearPop();
                    } else if (position == 2) {
                        showCityPop();
                    }
                }
            }
        });

        if (findPeopleAdapter == null) {
            findPeopleAdapter = new FindPeopleAdapter(getContext(), null, Glide.with(this));
        }
        findPeopleAdapter.setOnItemClick(new AdapterOnItemClick<FindPeopleEntity>() {
            @Override
            public void onItemClick(FindPeopleEntity findPeopleEntity, int position) {
                FindPeopleDetailActivity.start(getContext(), findPeopleEntity.getNo());
            }
        });

        binding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        binding.recyclerView.addItemDecoration(new RecyclerCustomDecoration(0,
                0,
                0,
                getResources().getDimension(R.dimen.dp5)));
        binding.recyclerView.setAdapter(findPeopleAdapter);
        binding.recyclerView.setLoadingMoreEnabled(true);
        binding.recyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                initFilterData(false);
            }

            @Override
            public void onLoadMore() {
                initFilterData(true);
            }
        });

        pickResultIndustry = new PickResultEntity();
        pickResultCategory = new PickResultEntity();
        pickResultWorkType = new PickResultEntity();
        pickResultWorkerLevel = new PickResultEntity();
        pickResultWorkYear = new PickResultEntity();
        pickResultProvince = new PickResultEntity();
        pickResultCity = new PickResultEntity();
        pickResultArea = new PickResultEntity();

        if (getArguments() != null) {
            mAddress = (AddressEntity) getArguments().getSerializable("entity");
        }

        mAreaCode = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.AREA_CODE, "");
        mAreaName = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.AREA_NAME, "");

        String provinceNo = "", cityNo = "", cityName = "";
        if (getArguments() != null) {
            provinceNo = getArguments().getString("provinceNo");
            industryNo = getArguments().getString("industryNo");
            categoryNo = getArguments().getString("categoryNo");
            workNo = getArguments().getString("workNo");
            cityNo = getArguments().getString("cityNo");
            cityName = getArguments().getString("cityName");
            workName = getArguments().getString("workName");
            time = getArguments().getString("time");
        }


        if (!TextUtils.isEmpty(provinceNo)) {
            pickResultProvince.setNo(provinceNo);
            pickResultCity.setNo(cityNo);
            pickResultCity.setName(cityName);
            binding.sct.contentSelect(cityName,true, false,3);
        }

        if (!TextUtils.isEmpty(industryNo)) {
            pickResultIndustry.setNo(industryNo);
            pickResultCategory.setNo(categoryNo);
            pickResultWorkType.setNo(workNo);

            String[] workNameArray = workName.split("/");

            binding.sct.contentSelect(workNameArray[workNameArray.length - 1],true, false,0);
        }

        binding.rvPackerChangeFirstContentTitle.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {

                carsTypePopWindow.setDefItem(tab.getPosition());
                if (tab.getPosition() != 0){
                    pickResultIndustry.setNo(workTypeList.get(tab.getPosition()).getNo());
                    pickResultIndustry.setName(workTypeList.get(tab.getPosition()).getName());
                }else {
                    pickResultIndustry.setNo("");
                    pickResultIndustry.setName("全部");
                }

                if (TextUtils.isEmpty(categoryNo)){
                    pickResultCategory.clear();
                    pickResultWorkType.clear();
                }

                initFilterData(false);

                if (tab.getPosition() == 0) {
                    binding.sct.removeTextButton(selectPopEntity3);
                    return;
                }else {
                    binding.sct.addTextButton(selectPopEntity3,0);
                    if (workName == null || "".equals(workName)){
                        binding.sct.contentSelect("工种",false,false,0);
                    }else {
                        String[] split = workName.split("/");
                        binding.sct.contentSelect(split[split.length - 1],true,false,0);
                    }
                }

                workName = null;

                List<PickFilterEntity<List<PickFilterEntity>>> data = new ArrayList<>(workTypeList.get(tab.getPosition()).getChildren());
                List<PickFilterEntity> oneLevelData = new ArrayList<>();
                data.add(0,new PickFilterEntity("","全部"));
                List<List<PickFilterEntity>> twoLevelData = new ArrayList<>();
                for (PickFilterEntity<List<PickFilterEntity>> datum : data) {
                    oneLevelData.add(datum);
                    List<PickFilterEntity> oneLevel = new ArrayList<>(datum.getChildren() == null ? new ArrayList<>() : datum.getChildren());
                    oneLevel.add(0,new PickFilterEntity("","全部"));
                    twoLevelData.add(oneLevel);
                }

                popWorkType = new TwoLevelPopWindow<>(getActivity());
                popWorkType.setBgView(binding.grayLayout);

                popWorkType.setPopClick(new PopClick<PickFilterEntity>() {
                    @Override
                    public void reset() {
                        pickResultCategory.clear();
                        pickResultWorkType.clear();
                        binding.sct.contentSelect("工种",false,false,0);
                        initFilterData(false);
                    }

                    @Override
                    public void sure(int provincePosition, int cityPosition, PickFilterEntity provinceEntity, PickFilterEntity cityEntity) {
                        if (provinceEntity != null){
                            pickResultCategory.setNo(provinceEntity.getNo());
                            pickResultCategory.setName(provinceEntity.getName());
                        }else {
                            pickResultCategory.setNo("");
                            pickResultCategory.setName("全部");
                        }

                        if (cityEntity != null){
                            pickResultWorkType.setNo(cityEntity.getNo());
                            pickResultWorkType.setName(cityEntity.getName());
                        }else {
                            pickResultWorkType.setNo("");
                            pickResultWorkType.setName("全部");
                        }

                        initFilterData(false);

                        if (TextUtils.equals(getString(R.string.app_all), pickResultWorkType.getName())) {
                            if (TextUtils.equals(getString(R.string.app_all), pickResultCategory.getName())){
                                binding.sct.contentSelect("工种",false,false,0);
                            }else {
                                binding.sct.contentSelect(pickResultCategory.getName(), true, false, 0);
                            }
                        } else {
                            binding.sct.contentSelect(pickResultWorkType.getName(),true,false,0);
                        }
                    }
                });
                popWorkType.setOnDismissListener(() -> binding.sct.contentSelect(!"工种".equals(binding.sct.getName(0)),false,0));

                if (!"".equals(categoryNo)) {
                    popWorkType.setLinkData(oneLevelData, twoLevelData, categoryNo, workNo);
                    categoryNo = "";
                } else {
                    popWorkType.setLinkData(oneLevelData, twoLevelData);
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

        carsTypePopWindow = new GoodsTypePopWindow4(getActivity());
        carsTypePopWindow.setBgView(binding.grayLayout);
        carsTypePopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object type, Object key2, Object key3) {
                GoodsInfoTypeEntity3 entity = (GoodsInfoTypeEntity3) type;
                typePosition = (int) key2;
                pickResultIndustry.setNo(entity.getNo());
                if (typePosition != 0){
                    binding.sct.addTextButton(selectPopEntity3,0);
                }
                binding.rvPackerChangeFirstContentTitle.postDelayed(() -> binding.rvPackerChangeFirstContentTitle.getTabAt(typePosition).select(), 100);
                initFilterData(false);
            }
        });
        carsTypePopWindow.setOnDismissListener(() -> binding.ivEmploymentAll.setImageResource(R.mipmap.btn_expand_team_employment));

        initLiveData();
    }

    private void initLiveData() {

        viewModel.loading.observe(getViewLifecycleOwner(), aBoolean -> DialogHelper.showProgressDialog(getContext(), null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false));

        viewModel.workerList.observe(getViewLifecycleOwner(), list -> {
            if (isLoadMore) {
                binding.recyclerView.loadMoreComplete();
                if (list != null && list.size() > 0) {
                    findPeopleAdapter.addDatas(list);
                }
                binding.recyclerView.setNoMore(list.size() < 10);
            } else {
                binding.recyclerView.refreshComplete();
                if (list != null && list.size() > 0) {
                    binding.emptyView.setVisibility(View.GONE);
                    findPeopleAdapter.setDatas(list);
                    binding.recyclerView.smoothScrollToPosition(0);
                } else {
                    findPeopleAdapter.clearDatas();
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
            }
        });

        viewModel.workLevel.observe(getViewLifecycleOwner(), new Observer<List<PickSelectEntity>>() {
            @Override
            public void onChanged(List<PickSelectEntity> pickSelectEntities) {
                if (popWorkerLevel == null) {
                    int position = 0;
                    popWorkerLevel = new PickPopWindow1(getContext());
                    popWorkerLevel.setBgView(binding.grayLayout);
                    if (!"".equals(pickResultWorkerLevel.getNo())) {
                        for (int i = 0; i < pickSelectEntities.size(); i++) {
                            if (pickSelectEntities.get(i).getNo().equals(pickResultWorkerLevel.getNo())) {
                                position = i;
                            }
                        }
                    }
                    popWorkerLevel.setOnResultClick((PickPopWindow1.OnResultClick) (key1, key2, key3) -> {
                        pickResultWorkerLevel.setNo((String) key1);
                        pickResultWorkerLevel.setName((String) key2);
                        pickResultWorkerLevel.setPosition((int) key3);
                        if (TextUtils.isEmpty((String) key1) || TextUtils.equals(getString(R.string.app_all), (String) key2)) {
                            binding.sct.contentSelect("专业职级",false,false,binding.sct.getSize() == 4 ? 1 : 0);
                        } else {
                            binding.sct.contentSelect((String) key2,true,false,binding.sct.getSize() == 4 ? 1 : 0);
                        }
                        initFilterData(false);
                    });
                    popWorkerLevel.setOnDismissListener(() -> binding.sct.contentSelect(!"专业职级".equals(binding.sct.getName(binding.sct.getSize() == 4 ? 1 : 0)),false,binding.sct.getSize() == 4 ? 1 : 0));

                    popWorkerLevel.setData(pickSelectEntities);
                    popWorkerLevel.setDefaultItem(position);
                }
            }
        });

        viewModel.typeList.observe(getViewLifecycleOwner(), new Observer<List<PickFilterEntity<List<PickFilterEntity<List<PickFilterEntity>>>>>>() {
            @Override
            public void onChanged(List<PickFilterEntity<List<PickFilterEntity<List<PickFilterEntity>>>>> pickFilterEntities) {
                workTypeList = pickFilterEntities;
                int position = 0;
                for (int i = 0; i < pickFilterEntities.size(); i++) {
                    PickFilterEntity pickFilterEntity = pickFilterEntities.get(i);
                    GoodsInfoTypeEntity3 info = new GoodsInfoTypeEntity3();
                    info.setName(pickFilterEntity.getName());
                    info.setNo(pickFilterEntity.getNo());
                    carsTypeData.add(info);
                    oneLevel.add(pickFilterEntity);
                    if (pickFilterEntity.getNo().equals(industryNo)){
                        position = i;
                    }
                    binding.rvPackerChangeFirstContentTitle.addTab(binding.rvPackerChangeFirstContentTitle.newTab().setText(pickFilterEntity.getName()));
                }

                int finalPosition = position;
                binding.rvPackerChangeFirstContentTitle.postDelayed(() -> binding.rvPackerChangeFirstContentTitle.getTabAt(finalPosition).select(),100);
            }
        });

        viewModel.workYearList.observe(getViewLifecycleOwner(), new Observer<List<PickSelectEntity>>() {
            @Override
            public void onChanged(List<PickSelectEntity> pickSelectEntities) {
                if (popWorkYear == null) {
                    int position = 0;
                    popWorkYear = new PickPopWindow1(getContext());
                    popWorkYear.setBgView(binding.grayLayout);
                    if (!"".equals(pickResultWorkYear.getNo())) {
                        for (int i = 0; i < pickSelectEntities.size(); i++) {
                            if (pickSelectEntities.get(i).getNo().equals(pickResultWorkYear.getNo())) {
                                position = i;
                            }
                        }
                    }
                    popWorkYear.setOnResultClick((PickPopWindow1.OnResultClick) (key1, key2, key3) -> {
                        pickResultWorkYear.setNo((String) key1);
                        pickResultWorkYear.setName((String) key2);
                        pickResultWorkYear.setPosition((int) key3);
                        if (TextUtils.isEmpty((String) key1) || TextUtils.equals(getString(R.string.app_all), (String) key2)) {
                            binding.sct.contentSelect("工龄",false,false,binding.sct.getSize() == 4 ? 2 : 1);
                        } else {
                            binding.sct.contentSelect((String) key2,true,false,binding.sct.getSize() == 4 ? 2 : 1);
                        }
                        initFilterData(false);
                    });
                    popWorkYear.setOnDismissListener(() -> binding.sct.contentSelect(!"工龄".equals(binding.sct.getName(binding.sct.getSize() == 4 ? 2 : 1)),false,binding.sct.getSize() == 4 ? 2 : 1));

                    popWorkYear.setData(pickSelectEntities);
                    popWorkYear.setDefaultItem(position);
                }
            }
        });

        viewModel.cityList.observe(getViewLifecycleOwner(), new Observer<List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>>>() {
            @Override
            public void onChanged(List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> addressEntities) {
                if (popCity == null) {
                    popCity = new ThreeLevelAreaWindow(getActivity()) {
                        @Override
                        protected void provinceClick(BaseAreaEntity baseAreaEntity, int position) {
                            super.provinceClick(baseAreaEntity, position);
                            pickResultProvince.setNo(baseAreaEntity.getNo());
                            pickResultProvince.setName(baseAreaEntity.getSimpleName());
                            if (getString(R.string.app_all).equals(baseAreaEntity.getSimpleName()) || pickResultProvince.getName().equals(baseAreaEntity.getSimpleName())) {
                                pickResultCity.setNo("");
                                pickResultCity.setName("");
                                pickResultArea.setNo("");
                                pickResultArea.setName("");
                            }
                        }

                        @Override
                        protected void cityClick(BaseAreaEntity baseAreaEntity, int position) {
                            super.cityClick(baseAreaEntity, position);
                            pickResultCity.setNo(baseAreaEntity.getNo());
                            pickResultCity.setName(baseAreaEntity.getSimpleName());
                            if (getString(R.string.app_all).equals(baseAreaEntity.getSimpleName()) || pickResultCity.getName().equals(baseAreaEntity.getSimpleName())) {
                                pickResultArea.setNo("");
                                pickResultArea.setName("");
                            }
                        }

                        @Override
                        protected void areaClick(BaseAreaEntity baseAreaEntity, int position) {
                            super.areaClick(baseAreaEntity, position);
                            pickResultArea.setNo(baseAreaEntity.getNo());
                            pickResultArea.setName(baseAreaEntity.getSimpleName());
                        }

                        @Override
                        protected void reset() {
                            super.reset();
                            pickResultProvince.clear();
                            pickResultCity.clear();
                            pickResultArea.clear();
                            binding.sct.contentSelect("全部",true,false,binding.sct.getSize() == 4 ? 3 : 2);
                            popCity.dismiss();
                            initFilterData(false);
                        }
                    };
                    popCity.setBgView(binding.grayLayout);
                    popCity.setShowSimpleName(true);
                    popCity.setProvinceSingle();
                    popCity.setCitySingle();
                    popCity.setAreaSingle();
                    pickResultProvince.setName(mAreaName);
                    popCity.setOnResultClick((key1, key2, key3) -> {
                        initFilterData(false);
                        if (!getString(R.string.app_all).equals(pickResultArea.getName()) && !"".equals(pickResultArea.getName())) {
                            binding.sct.contentSelect(pickResultArea.getName(),true,false,binding.sct.getSize() == 4 ? 3 : 2);
                            return;
                        } else {
                            binding.sct.contentSelect(pickResultCity.getName(),true,false,binding.sct.getSize() == 4 ? 3 : 2);
                        }

                        if (!getString(R.string.app_all).equals(pickResultCity.getName()) && !"".equals(pickResultCity.getName())) {
                            binding.sct.contentSelect(pickResultCity.getName(),true,false,binding.sct.getSize() == 4 ? 3 : 2);
                            return;
                        } else {
                            binding.sct.contentSelect(pickResultProvince.getName(),true,false,binding.sct.getSize() == 4 ? 3 : 2);
                        }

                        if (!getString(R.string.app_all).equals(pickResultProvince.getName()) && !"".equals(pickResultProvince.getName())) {
                            binding.sct.contentSelect(pickResultProvince.getName(),true,false,binding.sct.getSize() == 4 ? 3 : 2);
                        } else {
                            binding.sct.contentSelect("全部",true,false,binding.sct.getSize() == 4 ? 3 : 2);
                        }
                    });
                    popCity.setOnDismissListener(() -> binding.sct.contentSelect(!"地区".equals(binding.sct.getName(binding.sct.getSize() == 4 ? 3 : 2)),false,binding.sct.getSize() == 4 ? 3 : 2));

                    if (!"".equals(pickResultProvince.getNo())) {
                        popCity.setDataForTeamMainPage(addressEntities, true, pickResultProvince.getNo(), pickResultCity.getNo());
                    } else {
                        popCity.setDataForAll(addressEntities, true, mAreaCode);
                    }

                }
            }
        });
    }

    @Override
    protected void onLazyLoad() {
        if ("".equals(pickResultProvince.getNo())) {
            pickResultProvince.setNo(mAreaCode);
            binding.sct.contentSelect(mAreaName,true,false,3);
        }
        viewModel.getLinkAgeWorkType();
        initFilterData(false);
        viewModel.getWorkerLevel();
        viewModel.getWorkYear();
        viewModel.getCityList();
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.iv_employment_all){
            if (carsTypeData != null && carsTypeData.size() > 0){
                carsTypePopWindow.setData(carsTypeData,typePosition);
                carsTypePopWindow.showPopwindow(binding.ivEmploymentAll, 0, 0);
            }
            binding.ivEmploymentAll.setImageResource(R.mipmap.btn_expand_up_gray);
        }
    }

    /**
     * 工种
     *
     * @param
     */
    public void showWorkTypePop() {
        binding.sct.contentSelect(false, true,0);
        popWorkType.showPopwindow0(binding.sct);
    }

    /**
     * 工人级别pop
     *
     * @param
     */
    public void shoWorkerLevelPop() {
        binding.sct.contentSelect(false, true,binding.sct.getSize() == 4 ? 1 : 0);
        popWorkerLevel.showPopwindow0(binding.sct);
    }

    /**
     * 工龄pop
     *
     * @param
     */
    public void shoWorkYearPop() {
        binding.sct.contentSelect(false, true,binding.sct.getSize() == 4 ? 2 : 1);
        popWorkYear.showPopwindow0(binding.sct);
    }

    /**
     * 省市区pop
     *
     * @param
     */
    public void showCityPop() {
        binding.sct.contentSelect(false, true,binding.sct.getSize() == 4 ? 3 : 2);
        popCity.showPopwindow(binding.sct, 0, 0);
    }

    private void setTextButton(){
        selectPopEntity3 = new SelectPopEntity("工种", "1", false, true);
        SelectPopEntity selectPopEntity1 = new SelectPopEntity("专业职级", "2", false, true);
        SelectPopEntity selectPopEntity2 = new SelectPopEntity("工龄", "3", false, true);
        SelectPopEntity selectPopEntity4 = new SelectPopEntity("地区", "4", false, true);
        binding.sct.addTextButton(selectPopEntity3);
        binding.sct.addTextButton(selectPopEntity1);
        binding.sct.addTextButton(selectPopEntity2);
        binding.sct.addTextButton(selectPopEntity4);
    }

}
